package rdp.auto.clear;

import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;


import java.util.List;

import rdp.RDPUtil;

public class AUTOClearItem extends BukkitRunnable {
    private JavaPlugin plugin;
    private FileConfiguration conf;
    private int counter;
    private int countdown;
    private List<String> content;

    @Override
    public void run() {
        RDPUtil.NOTICE(content.get(1).replace("*-*", String.valueOf(countdown - counter)));
        if (counter + 1 == countdown) {
            RDPUtil.EXECUTE("kill @e[type=item]");
            RDPUtil.NOTICE(content.get(2));
            this.cancel();
        }
        counter++;
    }

    public void open(FileConfiguration conf, JavaPlugin plugin) {
        this.plugin = plugin;
        this.conf = conf;
        this.counter = 0;
        this.countdown = conf.getInt("countdown");
        this.content = conf.getStringList("content");
        runTaskTimer(plugin, 0, 20);
    }
}
